home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1997 #3 / Amiga Plus CD - 1997 - No. 03.iso / pd / programmierung / alienbreed3d2_src / readjoy.s < prev    next >
Text File  |  1997-01-31  |  2KB  |  116 lines

  1.  
  2.     opt    O+,D+,L+,P=68020
  3.  
  4.  
  5.     INCDIR    utils:sysinc
  6.     include "workbench:utilities/devpac/system.gs"
  7.     INCLUDE    libraries/lowlevel.i
  8. ;    INCLUDE    exec/exec_lib.i
  9.  
  10. _LVOReadJoyPort    EQU    -$1e
  11.  
  12.  
  13.     XDEF    _InitLowLevel
  14.  
  15. _InitLowLevel
  16.     lea    _lowlevel(pc),a1
  17.     moveq    #1,d0
  18.     move.l    4.w,a6
  19.     jsr    _LVOOpenLibrary(a6)
  20.     tst.l    d0
  21.     beq.s    .NoLowLib
  22.     move.l    d0,_LowBase
  23.  
  24.     rts
  25.  
  26. .NoLowLib
  27.     moveq    #-1,d0
  28.     rts
  29.  
  30.  
  31.     XDEF    _CloseLowLevel
  32.  
  33. _CloseLowLevel
  34.     move.l    _LowBase(pc),a1
  35.     tst.l    a1
  36.     beq.s    .Exit
  37.     move.l    4.w,a6
  38.     jsr    _LVOCloseLibrary(a6)
  39. .Exit
  40.     rts
  41.  
  42.  
  43.  
  44. ; pass port number in d0 0-3
  45.  
  46.     XDEF    _ReadJoy
  47. _ReadJoy
  48.  
  49.     move.l    _LowBase(pc),a6
  50.     jsr    _LVOReadJoyPort(a6)
  51.  
  52.     move.l    d0,d1
  53.  
  54.     and.l    #JP_TYPE_MASK,d1
  55.  
  56. ; bits in d1
  57.  
  58.  
  59.     cmp.l    #JP_TYPE_NOTAVAIL,d1     
  60.     beq.b    .Empty
  61.  
  62.     cmp.l    #JP_TYPE_GAMECTLR,d1 
  63.     beq.b    .GameCtrl
  64.  
  65.  
  66.  
  67.     cmp.l    #JP_TYPE_MOUSE,d1    
  68.     beq.b    .Mouse
  69.  
  70.     cmp.l    #JP_TYPE_JOYSTK,d1   
  71.     beq.b    .Joystick
  72.  
  73.  
  74. ;    cmp.l    #JP_TYPE_UNKNOWN,d1  
  75.  
  76.  
  77. ; type is an unknown type 
  78.  
  79. .Empty
  80.  
  81.     rts
  82.  
  83. .GameCtrl
  84.  
  85. ;    these are the bit defs..
  86.  
  87. ;     JPF_BUTTON_BLUE         Blue - Stop
  88. ;     JPF_BUTTON_RED          Red - Select
  89. ;     JPF_BUTTON_YELLOW       Yellow - Repeat
  90. ;     JPF_BUTTON_GREEN        Green - Shuffle
  91. ;     JPF_BUTTON_FORWARD      Charcoal - Forward
  92. ;     JPF_BUTTON_REVERSE      Charcoal - Reverse
  93. ;     JPF_BUTTON_PLAY         Grey - Play/Pause
  94. ;     JPF_JOY_UP              Up
  95. ;     JPF_JOY_DOWN            Down
  96. ;     JPF_JOY_LEFT            Left
  97. ;     JPF_JOY_RIGHT           Right
  98.  
  99. .Joystick
  100.  
  101. .Mouse
  102.     rts
  103.  
  104.  
  105.  
  106. Data:
  107.  
  108. _LowBase
  109.     dc.l    0
  110.  
  111. _lowlevel
  112.     dc.b    'lowlevel.library',0
  113.     even
  114.  
  115.     END
  116.